package Controls
{
	import Input.GameInput;
	
	import Objects.GameBitmap;
	import Objects.GameSprite;
	
	import Tools.BitmapTool;
	
	import flash.display.BitmapData;
	import flash.display.SimpleButton;
	
	public class Interactive extends GameSprite
	{
		private var onImage:BitmapData;
		private var overImage:BitmapData;
		private var downImage:BitmapData;
		private var overGlow:Boolean=false;
		public var image:GameBitmap;
		public function Interactive()
		{
			super();
			
			image=new GameBitmap();
			addChild(image);
			
			intelligent=true;
		}
		override protected function $update():void
		{
			if(!selected)
			{
				if(mOver)
				{
					if(overGlow)
					{
						doGlow();
					}
					if(mDown)
					{
						image.setImage(downImage);
					}
					else
					{
						image.setImage(overImage);
					}
				}
				else
				{
					if(overGlow)
					{
						unGlow();
					}
					image.setImage(onImage);
				}
			}
			else
			{
				if(overGlow)
				{
					unGlow();
				}
				image.setImage(downImage);
			}
		}
		protected function doGlow():void
		{
			tint(0x646464);
		}
		protected function unGlow():void
		{
			tint(0x000000);
		}
		public function setup(onImageData:Object,overImageData:Object=null,downImageData:Object=null):void
		{
			onImage=BitmapTool.getImageByData(onImageData);
			if(overImageData)
			{
				overImage=BitmapTool.getImageByData(overImageData);
			}
			else
			{
				overGlow=true;
				overImage=onImage;
			}
			if(downImageData)
			{
				downImage=BitmapTool.getImageByData(downImageData);
			}
			else
			{
				downImage=overImage;
				
			}
			image.setImage(onImage);
		}
	}
}